//
//	 ______    ______    ______    
//	/\  __ \  /\  ___\  /\  ___\   
//	\ \  __<  \ \  __\_ \ \  __\_ 
//	 \ \_____\ \ \_____\ \ \_____\ 
//	  \/_____/  \/_____/  \/_____/ 
//
//	Powered by BeeFramework
//
//
//  AddFriendBoard.m
//  iHeima
//
//  Created by he chao on 5/29/14.
//  Copyright (c) 2014 leon. All rights reserved.
//

#import "AddFriendBoard.h"
#import "AddContactBoard.h"


#import "SearchPBoard.h"
#pragma mark -

@interface AddFriendBoard()
{
	//<#@private var#>
}
@end

@implementation AddFriendBoard
DEF_SIGNAL(WECHAT)
DEF_SIGNAL(WECHAT_CIRCLE)
DEF_SIGNAL(SMS)

- (void)load
{
}

- (void)unload
{
}

#pragma mark - Signal

ON_CREATE_VIEWS( signal )
{
    self.title = @"添加好友";
    [self showBarButton:BeeUINavigationBar.LEFT image:IMAGESTRING(@"navi_back")];
    [self showNaviBar];
    [self loadContent];
}

ON_DELETE_VIEWS( signal )
{
}

ON_LAYOUT_VIEWS( signal )
{
}

ON_WILL_APPEAR( signal )
{
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

ON_DID_APPEAR( signal )
{
}

ON_WILL_DISAPPEAR( signal )
{
}

ON_DID_DISAPPEAR( signal )
{
}

ON_SIGNAL3( BeeUINavigationBar, LEFT_TOUCHED, signal )
{
    [self.stack popBoardAnimated:YES];
}

ON_SIGNAL3( BeeUINavigationBar, RIGHT_TOUCHED, signal )
{
}

- (void)loadContent{
    myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.viewWidth, self.viewHeight-50-(IOS7_OR_LATER?64:0))];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    [self.view addSubview:myTableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60.0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
    if (nil == cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell1"];
    }
    for (id element in [cell.contentView subviews]) {
        [element removeFromSuperview];
    }
    //[cell load];
    NSArray *title = @[@"邀请好友加入",@"查找感兴趣的人",@"手机通讯录添加好友"];
    NSString *strIcon = [NSString stringWithFormat:@"add_friend_%d",indexPath.row];
    BeeUIImageView *imgIcon = [BeeUIImageView spawn];
    imgIcon.frame = CGRectMake(10, 9, 42, 42);
    imgIcon.image = IMAGESTRING(strIcon);
    [cell.contentView addSubview:imgIcon];
    
    
    BaseLabel *label = [BaseLabel initLabel:title[indexPath.row] font:FONT(14) color:kNormalColor textAlignment:NSTextAlignmentLeft];
    label.frame = CGRectMake(imgIcon.right+10, 0, 200, 60);
    [cell.contentView addSubview:label];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
        {
            BeeUIActionSheet *sheet = [BeeUIActionSheet spawn];
            [sheet addButtonTitle:@"邀请微信的朋友" signal:AddFriendBoard.WECHAT];
            [sheet addButtonTitle:@"分享到微信朋友圈" signal:AddFriendBoard.WECHAT_CIRCLE];
            [sheet addButtonTitle:@"短信邀请" signal:AddFriendBoard.SMS];
            [sheet addCancelTitle:@"取消"];
            [sheet showInViewController:self];
        }
            break;
        case 1:
        {
            
            SearchPBoard* board = [[SearchPBoard alloc]init];
            [self.stack pushBoard:board animated:YES];
            
            
        }
            break;
        case 2:
        {
            AddContactBoard *board = [[AddContactBoard alloc] init];
            [self.stack pushBoard:board animated:YES];
        }
            break;
            
        default:
            break;
    }
}

@end
